<?php
namespace app\app\controller;

use alisms\Alidayu;
use app\common\controller\App;
use Common\utils\Alisms;
use extend\alisms\AlismsApi;
use think\captcha\Captcha;
use think\Config;
use think\console\command\optimize\Schema;
use think\console\command\Version;
use think\Db;
use think\Exception;
use think\route\Rule;

/**
 * 公共方法，发送短信、省市区三级联动等
 */
class Guizhang extends App
{


    //规章制度列表
    public function list()
    {

        $member=$this->getAppLoginInfo();
        $house_id=empty($member['house_id'])?0:$member['house_id'];

        $data=Db::name("Guizhang")
             ->order("id desc")
             ->where(['house_id'=>$house_id])
             ->select();
        if (!empty($data)){
            foreach ($data as $key=>$val){
                $data[$key]['create_time']=date("Y年m月d日",$val['create_time']);
                $data[$key]['image_path']=model("File")->getPath($val['images']);
                $data[$key]['content']=trimAll($val['content']);
            }
        }

        return $this->ok('请求成功',$data);

    }







    //规章详情
    public function detail()
    {
        $id=request()->param("id",'0','intval');
        $detail=Db::name("Guizhang")->where(['id'=>$id])->find();
        if (empty($detail)){
            return $this->fail('规章不存在');
        }else{
            $detail['create_time']=date("Y年m月d日",$detail['create_time']);
            $detail['images']=model("File")->getPaths($detail['images']);
            return $this->ok('请求成功',$detail);
        }
    }
}
